package com.shi.yoyoshop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shi.yoyoshop.bean.Top;
import com.shi.yoyoshop.mapper.TopMapper;
import com.shi.yoyoshop.service.TopService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TopServiceImpl extends ServiceImpl<TopMapper, Top> implements TopService {

    @Resource
    private TopMapper topMapper;

    @Override
    public List<Top> getTopListByGoodsId(Integer id) {
        return topMapper.selectList(new LambdaQueryWrapper<Top>()
                .select(Top::getId, Top::getType, Top::getGoodId)
                .eq(Top::getGoodId, id));
    }

    @Override
    public void removeByGoodsIdAndType(Integer goodsId, Integer type) {
        topMapper.delete(new LambdaQueryWrapper<Top>().eq(Top::getGoodId, goodsId).eq(Top::getType, type));
    }

}
